package edu.um.expression;

import edu.um.analyzer.exception.TypeMismatchException;

/**
 *
 * @author diego.gluj
 *
 */
public class TwoTermsValidation extends Validation {

  /**
   *
   */
  private final ExpressionTreeNode secondExpression;

  private final ValidationStrategy strategy;

  public TwoTermsValidation(ExpressionTreeNode theExpression,
      ExpressionTreeNode theSecondExpression, ValidationStrategy theStrategy) {
    super(theExpression);
    this.secondExpression = theSecondExpression;
    this.strategy = theStrategy;
  }

  @Override
  public String toString() {
    return super.toString() + "::" + secondExpression.toString();
  }

  @Override
  public void run() throws TypeMismatchException {
    super.run();
    secondExpression.validate();
    strategy.validate(expression, secondExpression);
  }
}
